Page({

  /**
   * 页面的初始数据
   */
  data: {
    covidList: [],
    confirmedCount: 0,
    suspectedCount: 0,
    currentConfirmedCount: 0,
    deadCount: 0,
    curedCount: 0,
    headerArray: [{
      text: '地区',
    }, {
      text: '现存确诊'
    }, {
      text: '死亡'
    }, {
      text: '治愈'
    }],
  },

  getRequest() {
    var that = this;
    wx.request({
      url: 'http://localhost:8080/clock_war_exploded//covid19Data/updateData',
      method:'POST',
      header:{'content-type':'application/x-www-form-urlencoded;charset=utf-8'},
    })
    wx.request({
      url: 'http://localhost:8080/clock_war_exploded//covid19Data/findAll',
      method:'POST',
      header:{'content-type':'application/x-www-form-urlencoded;charset=utf-8'},
      success: function(res) {
        if (res.data != null) {
          res.data.forEach(item=>{
            that.data.confirmedCount+= item.confirmedCount
            that.data.suspectedCount+= item.suspectedCount
            that.data.currentConfirmedCount+= item.currentConfirmedCount
            that.data.deadCount+= item.deadCount
            that.data.curedCount+= item.curedCount
          })
          that.setData({
            covidList: res.data,
            confirmedCount: that.data.confirmedCount,
            suspectedCount: that.data.suspectedCount,
            currentConfirmedCount: that.data.currentConfirmedCount,
            deadCount: that.data.deadCount,
            curedCount: that.data.curedCount
          })
        }
      }
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getRequest()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    
  }
})